package com.ruoyi.web.controller.spoken;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SpokenLessonNum;
import com.ruoyi.system.service.ISpokenLessonNumService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "课时包管理")
@RequestMapping("/spoken/lessonNum")
@RestController
public class LessonNumController extends BaseController {

    @Autowired
    ISpokenLessonNumService lessonNumService;

    @ApiOperation("课时包列表")
    @GetMapping("/list")
    public TableDataInfo list(SpokenLessonNum lessonNum){
        startPage();
        return getDataTable(lessonNumService.selectList(lessonNum));
    }

    @ApiOperation("添加课时包")
    @PostMapping
    public AjaxResult add(@RequestBody SpokenLessonNum lessonNum){
        return success(lessonNumService.insert(lessonNum));
    }

    @ApiOperation("查询课时包")
    @GetMapping("/{lessonId}")
    public AjaxResult getbyId(@PathVariable Long lessonId){
        return success(lessonNumService.selectById(lessonId));
    }

    @ApiOperation("修改课时包")
    @PutMapping
    public AjaxResult edit(@RequestBody SpokenLessonNum lessonNum){
        return success(lessonNumService.update(lessonNum));
    }

    @ApiOperation("删除课时包")
    @DeleteMapping("/{lessonId}")
    public AjaxResult remove(@PathVariable Long lessonId){
        return success(lessonNumService.delete(lessonId));
    }

}
